package com.neuedu.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.neuedu.dto.PageDto;
import com.neuedu.service.EmpService;
import com.neuedu.service.Impl.EmpServiceImpl;

/**
 * Servlet implementation class FenYeServlet
 */
@WebServlet("/FenYeServlet")
public class FenYeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FenYeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		Integer pageNum = 1;
		String str = request.getParameter("pageNum");
		if(str != null) {
			pageNum = Integer.parseInt(str);
		}
		
		//2 
		EmpService empService = new EmpServiceImpl();
		PageDto dto = empService.fenye(pageNum);
		//3
		HttpSession session = request.getSession();
		session.setAttribute("dto", dto);
		response.sendRedirect("FenYe.jsp");
		
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
